import axios from 'axios';
import qs from 'querystring';

export const getNodeDetail = params => {
  return axios.get(`/api/system/getNodeDetail?${qs.stringify(params)}`);
};

export const getNodeVersion = () => {
  return axios.get('/api/system/getNodeVersion');
};

export const getNotClusterNodeList = time => {
  return axios.get(`/api/system/getNodeList?created=${time}`);
};

export const getConnectedNodes = () => {
  return axios.get('/api/cluster/connectedNodes');
};

export const getNodeList = () => {
  return axios.get('/api/cluster/node/list');
};

export const removeNode = body => {
  return axios.post('/api/cluster/node/remove', body);
};

export const reloadNode = body => {
  return axios.post('/api/cluster/node/reload', body);
};

export const closeNode = body => {
  return axios.post('/api/cluster/node/close', body);
};

export const nodeLogs = ip => {
  return axios.get(`/api/cluster/node/logs?ip=${ip}`);
};

export const updateNode = body => {
  return axios.post('/api/cluster/node/update', body);
};

export const addNode = body => {
  return axios.post('/api/cluster/node/add', body);
};

export const nodeInfo = ip => {
  return axios.get(`/api/cluster/node/info?ip=${ip}`);
};
